/**
 *
 * User: Zhikang.Peng
 * Date: 2018/04/10 17:12
 */
package stores

import (
	"gitee.com/thghh/jvmgo/instructions/base"
	"gitee.com/thghh/jvmgo/rtda"
)

// 将栈顶引用型数值存入指定本地变量
type ASTORE struct{ base.Index8Instruction }

func (self *ASTORE) Execute(frame *rtda.Frame) {
	_astore(frame, uint(self.Index))
}

// 将栈顶引用型数值存入第一个本地变量
type ASTORE_0 struct{ base.NoOperandsInstruction }

func (self *ASTORE_0) Execute(frame *rtda.Frame) {
	_astore(frame, 0)
}

// 将栈顶引用型数值存入第二个本地变量
type ASTORE_1 struct{ base.NoOperandsInstruction }

func (self *ASTORE_1) Execute(frame *rtda.Frame) {
	_astore(frame, 1)
}

// 将栈顶引用型数值存入第三个本地变量
type ASTORE_2 struct{ base.NoOperandsInstruction }

func (self *ASTORE_2) Execute(frame *rtda.Frame) {
	_astore(frame, 2)
}

// 将栈顶引用型数值存入第四个本地变量
type ASTORE_3 struct{ base.NoOperandsInstruction }

func (self *ASTORE_3) Execute(frame *rtda.Frame) {
	_astore(frame, 3)
}

func _astore(frame *rtda.Frame, index uint) {
	val := frame.OperandStack().PopReference()
	frame.LocalVars().SetReference(index, val)
}

//func (self *IASTORE) Execute(frame *rtda.Frame)  { _lstore(frame, 0) }
//func (self *LASTORE) Execute(frame *rtda.Frame)  { _lstore(frame, 1) }
//func (self *FASTORE	) Execute(frame *rtda.Frame) { _lstore(frame, 2) }
//func (self *DASTORE	) Execute(frame *rtda.Frame) { _lstore(frame, 3) }
//func (self *AASTORE	) Execute(frame *rtda.Frame) { _lstore(frame, 0) }
//func (self *BASTORE	) Execute(frame *rtda.Frame) { _lstore(frame, 1) }
//func (self *CASTORE	) Execute(frame *rtda.Frame) { _lstore(frame, 2) }
//func (self *SASTORE	) Execute(frame *rtda.Frame) { _lstore(frame, 3) }
